<?php
defined('IN_ADMIN') or exit('No permission resources.');
include $this->admin_tpl('header','admin');
?>
<script type="text/javascript">
<!--
	$(function(){
		$.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'200',height:'50'}, function(){this.close();$(obj).focus();})}});
        $('#reg_id').formValidator({onshow:"请选择报名",onfocus:"请选择报名",oncorrect:"<?php echo L('right_all')?>"}).inputValidator({min:1,onerror:"请选择报名"});		
	})
//-->
</script>
<div class="pad-lr-10">
<form action="?m=sign_up&c=reg&a=add_reg_power" method="post" id="myform">
	<table width="100%"  class="table_form">
        <tr>
        <th width="120">报名类型：</th>
        <td class="y-bg">
            <?php echo form::select($reg_type,'',' name="reg_type" id="reg_type" ','请选择')?>
        </td>
        </tr>
        <tr>
        <th width="120">报名赛区：</th>
        <td class="y-bg">
            <?php echo form::select($contest_district,'',' name="contest_district" id="contest_district" ','请选择')?>
        </td>
        </tr>
        <tr>
        <th width="120">报名：</th>
        <td class="y-bg">
            <?php echo form::select($regList,'',' name="reg_id" id="reg_id" ','请选择')?>
        </td>
        </tr>
        <?php foreach($role as $v){?>
        <tr>
        <th width="120"><?php echo $v['name']?>：</th>
        <td class="y-bg">
        <?php foreach($v['user_list'] as $vo){?>
            <input type="checkbox" name="user_id[]" value="<?=$vo['userid']?>" ><?=$vo['realname']?>
        <?php }?>
        </td>
        </tr>
        <?php }?>
    </table>
<div class="bk15"></div>
    <input type="submit" class="dialog" id="dosubmit" name="dosubmit" value="<?php echo L('submit');?>" />
</form>
</div>
<script language="JavaScript">
<!--
	$('#reg_type').change(function(){
        var reg_type = $(this).val();
        if (reg_type) {
            $.ajax({
                type:"post",
                url:"?m=sign_up&c=reg&a=ajax_reg_district&pc_hash=<?php echo $_SESSION['pc_hash'];?>",
                dataType: "json",
                data: {reg_type:reg_type,type:1},
                success:function(data){
                    if(data.status){
                        var jsonobjs =  data.division_list;
                        var jsonobj =  data.reg_list;  
                        var _htmls = _html = '<option value="">请选择</option>';
                        for(key in jsonobj){
                            _html +='<option value="'+jsonobj[key]['id']+'">'+jsonobj[key]['title']+'</option>';
                        }
                        for(key in jsonobjs){
                            _htmls +='<option value="'+key+'">'+jsonobjs[key]+'</option>';
                        }
                        $('#contest_district').html(_htmls);
                        $('#reg_id').html(_html);
                    }else{
                        return false;
                    }
                }
            })
        } else {
            return false;
        }
    })
    $('#contest_district').change(function(){
        var district = $(this).val();
        var reg_type = $('#reg_type').val();
        if (district) {
            $.ajax({
                type:"post",
                url:"?m=sign_up&c=reg&a=ajax_reg_district&pc_hash=<?php echo $_SESSION['pc_hash'];?>",
                dataType: "json",
                data: {reg_type:reg_type,district:district},
                success:function(data){
                    if(data.status){
                        var jsonobj =  data.list;  
                        var _html = '<option value="">请选择</option>';
                        for(key in jsonobj){
                            _html +='<option value="'+jsonobj[key]['id']+'">'+jsonobj[key]['title']+'</option>';
                        }
                        $('#reg_id').html(_html);
                    }else{
                        return false;
                    }
                }
            })
        } else {
            return false;
        }
    })
	//-->
</script>
</body>
</html>